package com.example.dessert.controller.fore;

import com.example.dessert.controller.BaseController;
import com.example.dessert.entity.Advert;
import com.example.dessert.entity.Product;
import com.example.dessert.service.AdvertService;
import com.example.dessert.service.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: IndexController
 * @Description:
 * @Author li
 * @Date 2022/1/4
 * @Version 1.0
 */
@Controller
@RequestMapping("/fore")
public class IndexController extends BaseController {

    @Resource
    private AdvertService advertService;
    @Resource
    private ProductService productService;

    /**
     * 首页
     */
    @GetMapping("/index")
    public String index(Model model) {

        List<Advert> advert = advertService.queryAdvertList();
        logger.info("Query advert list results :{}", advert);

        //查询推荐商品
        List<Product> recommend = productService.queryRecommendProduct();
        logger.info("Query Recommend Product list results :{}", advert);

        model.addAttribute("advert", advert);
        model.addAttribute("recommend", recommend);

        return "fore/index";

    }

}
